package com.shwread.android.qysw.step.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shwread.android.qysw.step.dto.HMMyScore;
import com.shwread.android.qysw.tools.Screen;
import com.shwread.android.qysw.tools.TimeHelper;
import com.shwread.android.qysw10000243.R;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by Fantasy on 16/4/3.
 */
public class MyScoreAdapter extends LoadMoreListViewAdapter {
    private Context mContext;

    public MyScoreAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public RecyclerView.ViewHolder subOnCreateViewHolder(ViewGroup parent, int viewType) {
        View rootView = LayoutInflater.from(parent.getContext()).inflate(R.layout.h_score_item, null);
        rootView.setLayoutParams(new RecyclerView.LayoutParams(Screen.getScreenWidth(), ViewGroup.LayoutParams.WRAP_CONTENT));
        RecyclerView.ViewHolder itemViewHolder = new MyScoreViewHolder(rootView);
        return itemViewHolder;
    }

    @Override
    public void subOnBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MyScoreViewHolder myScoreViewHolder = (MyScoreViewHolder) holder;
        HMMyScore hmMyScore = (HMMyScore) getTotal_data_list().get(position);
        myScoreViewHolder.contentText.setText(hmMyScore.getContent() + "    " + TimeHelper.getDateY_M_D_TimByStamp(hmMyScore.getCreateTime()));
        myScoreViewHolder.scoreText.setText("+" + hmMyScore.getScores());
    }

    static class MyScoreViewHolder extends RecyclerView.ViewHolder {
        @InjectView(R.id.score_text)
        TextView scoreText;
        @InjectView(R.id.content_text)
        TextView contentText;

        MyScoreViewHolder(View view) {
            super(view);
            ButterKnife.inject(this, view);
        }
    }
}
